<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta charset="utf-8"/>
    <title><?php echo ($current['title']); ?>-<?php echo (C("sitename")); ?></title>

    <meta name="keywords" content="<?php echo (C("keywords")); ?>"/>
    <meta name="description" content="<?php echo (C("description")); ?>"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>


    <!-- bootstrap & fontawesome -->
    <link rel="stylesheet" href="/Public/qwadmin/css/bootstrap.css"/>
    <link rel="stylesheet" href="/Public/qwadmin/css/font-awesome.css"/>
    <link rel="stylesheet" href="/Public/qwadmin/css/jquery-ui.css"/>
    <!-- page specific plugin styles -->

    <!-- text fonts -->
    <link rel="stylesheet" href="/Public/qwadmin/css/ace-fonts.css"/>

    <!-- ace styles -->
    <link rel="stylesheet" href="/Public/qwadmin/css/ace.css" class="ace-main-stylesheet" id="main-ace-style"/>
    
    <!--[if lte IE 9]>
    <link rel="stylesheet" href="/Public/qwadmin/css/ace-part2.css" class="ace-main-stylesheet"/>
    <![endif]-->

    <!--[if lte IE 9]>
    <link rel="stylesheet" href="/Public/qwadmin/css/ace-ie.css"/>

    <![endif]-->

    <!-- inline styles related to this page -->

    <!-- ace settings handler -->
    <script src="/Public/qwadmin/js/ace-extra.js"></script>

     


        

     

</head>
<style type="text/css">
  
	.datainfo a,label{
		
		display: inline-block;
		margin: 15px 0px 15px 15px;
		font-weight:100;
	}
	.selected{
		background: #ccc;
	}
	.show-search{
          width: 100%;
          height: 0px;
          margin:10px auto;
          overflow: hidden;
	}
</style>
  
<div class="container" style="width: 90%;background: #fff;">
	<div class="row">
		<div class="col-xs-12">
			<h3 class="header smaller lighter blue">学生入伍信息管理</h3>
			<div class="table-header">
				毕业进军营，只为“打得赢”（卫国保安宁）大学生参军，一颗赤子心投笔从戎到军营锤炼成才， 报效祖国在部队建功立业学文读理为成才，尚武从军固国防奉献青春意境高 报效祖国心志远。
			</div>
					
			<div class="row">
				<div class="col-xs-6 datainfo">
					<a  href="#">					
						<button class="btn btn-primary btn-xs" onclick="dept.add()">新增</button>
					</a>
					<a href="#">	
						<button class="btn btn-danger btn-xs" onclick="dept.delAll()">批量删除</button>
					</a>
				</div>
				<div class="col-xs-6 datainfo align-right">
					    
				       <label>				       	  
				          <button class="btn btn-primary btn-xs" id="btn-search">查询数据</button>
				       </label>
				</div>
			</div>
			<!-- <div> -->
			    <div class="show-search">
				    	   <form class="form-inline">
								  <div class="form-group">
								    <label for="InputName01">学号</label>
								    <input type="text" class="form-control" id="InputName01" placeholder="请输入学号" name='XH'>
								  </div>
								  <div class="form-group">
								    <label for="InputName02">姓名</label>
								    <input type="text" class="form-control" id="InputName02" placeholder="请输入姓名" name='XM'>
								  </div>
								  <div class="form-group">
								    <label for="InputName03">身份证号</label>
								    <input type="text" class="form-control" id="InputName03" placeholder="请输入身份证号" name='SFZH'>
								  </div>
								  <div class="form-group">
								  <label for="InputName04">入学时间从</label>
								     <input type="text" class="form-control" id="InputName04" placeholder="时间起点" name='SJQD'>
								     ~ <input type="text" class="form-control"  placeholder="时间终点" name='SJZD'>
								  </div>
								 
		   <a class="btn btn-success btn-xs" style="margin-left: 10px" onclick="dept.search($(this).closest('form'))" id="search">查询</a>
							</form>
			       </div>
            





				<table id="sample-table-2" class="table  table-bordered table-hover">
					<thead>
						<tr>
							<th class="center">
								<label class="position-relative">
										<input type="checkbox" class="ace" />
										<span class="lbl"></span>
								</label>
							</th>

							<th>ID</th>
							<th>专业</th>
							<th>学号</th>
							<th>姓名</th>
							<th>姓别</th>
							<th style="display: none"class="XLDM">学历</th>       
							<th style="display: none"class="RXSJ">入学时间</th>
							<th style="display: none"class="AGE">年龄</th>


	                        <th></th>
	                        <th></th>
						</tr>
					</thead>
					<!--循环遍历-->
					<tbody class="datagrid">
					<?php if(is_array($infolist)): $i = 0; $__LIST__ = $infolist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?><tr>
							<td class="center">
								<label class="position-relative">
									<input type="checkbox" class="ace" />
									<span class="lbl"></span>
								</label>
							</td>

							<td><?php echo ($vo["id"]); ?></td>
							<td><?php echo ($vo["bjhm"]); ?></td>
							<td class="xh"><?php echo ($vo["xh"]); ?></td>
							<td><?php echo ($vo["xm"]); ?></td>					
							<td><?php echo ($vo["xbdm"]); ?></td>	
							<td style="display: none" class="XLDM"><?php echo ($vo["xldm"]); ?></td>
							<td style="display: none" class="RXSJ"><?php echo ($vo["rxsj"]); ?></td>
							<td style="display: none" class="AGE"><?php echo ($vo["age"]); ?></td>



							<td ><span class="label label-sm label-warning">Expiring</span></td>
							<td>
								<div class=" action-buttons text-center">
								
									<a class="green" href="#">
										
										<button class="btn btn-grey btn-minier" onclick="dept.edit($(this).closest('tr'))">编辑</button>

									</a>

									<a class="red" href="#">
										
									<button class="btn btn-danger btn-minier" onclick="dept.del($(this).closest('tr'))">删除</button>

									</a>
								</div>

								
							</td>
						</tr><?php endforeach; endif; else: echo "" ;endif; ?>
					</tbody>
				</table>
					       
			</div>
			  <!-- 用户操作弹出框 -->
			<div class="modal fade" tabindex="-1" role="dialog" id="oper-modal">
					  <div class="modal-dialog" role="document">
					    <div class="modal-content">
					      <div class="modal-header">
					        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					        <h4 class="modal-title">用户操作</h4>
					      </div>
					      <div class="modal-body">
					           <form class="form-horizontal" id="myform">
					                  <div class="form-group">
									    <label  class="col-sm-offset-2 col-sm-2 control-label" style="line-height:0px">专业</label>
									    <div class="col-sm-6">
									      <input type="text" class="form-control"  placeholder="请输入专业" name="BJHM">
									    </div>
									  </div>
									  <div class="form-group">
									    <label class="col-sm-offset-2 col-sm-2 control-label" style="line-height:0px">学号</label>
									    <div class="col-sm-6">
									      <input type="text" class="form-control"  placeholder="请输入学号" name="XH">
									    </div>
									  </div>
									  <div class="form-group">
									    <label  class="col-sm-offset-2 col-sm-2 control-label" style="line-height:0px">姓名</label>
									    <div class="col-sm-6">
									      <input type="text" class="form-control" placeholder="请输入姓名" name="XM">
									    </div>
									  </div>
									  <div class="form-group">
									    <label  class="col-sm-offset-2 col-sm-2 control-label" style="line-height:0px">姓别</label>
									    <div class="col-sm-6">
									      <input type="text" class="form-control" placeholder="请输入姓别" name="XBDM">
									    </div>
									  </div>
									   <div class="form-group">
									    <label  class="col-sm-offset-2 col-sm-2 control-label" style="line-height:0px">学历</label>
									    <div class="col-sm-6">
									      <input type="text" class="form-control" placeholder="请输入学历" name="XLDM">
									    </div>
									  </div>
									  <div class="form-group">
									    <label  class="col-sm-offset-2 col-sm-2 control-label" style="line-height:0px" >入伍时间</label>
									    <div class="col-sm-6">
									      <input type="text" class="form-control"  placeholder="入伍时间" name='RXSJ'>
									    </div>
									      <input type="reset" name="reset" style="display: none;" />

									  </div>
									  
									 
									  <div class="form-group">
									    <div class="col-sm-offset-2 col-sm-10">
									      <button type="submit" class="btn btn-default">Sign in</button>
									    </div>
									  </div>
								</form>
					      </div>
					      <div class="modal-footer">
					        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
					        <button type="button" class="btn btn-primary" onclick="dept.save()">保存</button>
					      </div>
					    </div><!-- /.modal-content -->
							  </div><!-- /.modal-dialog -->
			        </div><!-- /.modal -->


                  <!--  <?php if(is_array($arr1)): $i = 0; $__LIST__ = $arr1;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$du): $mod = ($i % 2 );++$i;?><a><?php echo ($du["AGE"]); ?></a><?php endforeach; endif; else: echo "" ;endif; ?> -->

                   <!-- 增加字段弹框 -->
                   <div class="modal fade" tabindex="-1" role="dialog" id="field-modal">
					  <div class="modal-dialog" role="document">
					    <div class="modal-content">
					      <div class="modal-header">
					        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					        <h4 class="modal-title">请选择要展示的字段</h4>
					      </div>
					      <div class="modal-body" id="addfields">
					           <!-- 主体 -->
                             <form id="pp">
                             	<!-- <?php if(is_array($fieldlist)): $i = 0; $__LIST__ = $fieldlist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i;?><input type="checkbox" value="<?php echo ($v["field"]); ?>" name="<?php echo ($v["field"]); ?>"><?php echo ($v["field"]); ?>&nbsp;&nbsp;&nbsp;<?php endforeach; endif; else: echo "" ;endif; ?>  --> 	
                             
                                 
					             <?php if(is_array($fieldlist)): $i = 0; $__LIST__ = $fieldlist;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$v): $mod = ($i % 2 );++$i; if(($v["field"] == 'XH') OR ($v["field"] == 'XM') OR ($v["field"] == 'XBDM') OR ($v["field"] == 'ID')OR ($v["field"] == 'BJHM')): ?><input type="checkbox" checked disabled value="<?php echo ($v["field"]); ?>" name="<?php echo ($v["field"]); ?>"><?php echo ($v["field"]); ?>&nbsp;&nbsp;&nbsp;      
								    <?php else: ?> 
								         <input type="checkbox" value="<?php echo ($v["field"]); ?>" name="<?php echo ($v["field"]); ?>"><?php echo ($v["field"]); ?>&nbsp;&nbsp;&nbsp;<?php endif; endforeach; endif; else: echo "" ;endif; ?>  
                               </form>
                               <a class="btn btn-success btn-xs">全选</a>
					      </div>
					      <div class="modal-footer">
					        <a type="button" class="btn btn-default" data-dismiss="modal">关闭</a>
					        <a  type="button" class="btn btn-primary" onclick="dept.saveField()">保存</a>
					      </div>
					    </div><!-- /.modal-content -->
					  </div><!-- /.modal-dialog -->
					</div><!-- /.modal -->

			    <button class="btn btn-success" id="addField">增加显示字段</button>
			     <!-- 分页 -->
			     <div style="margin-left: 45%;"><?php echo ($page); ?></div>
				    <div class="footer">
        <div class="footer-inner">
            <!-- #section:basics/footer -->
            <div class="footer-content">
                            <span class="bigger-120">
                                <small>Copyright &copy; <a href="http://www.hncxhd.com" target="_blank"><?php echo (C("footer")); ?></a> All Rights Reserved.</small>
                            </span>
            </div>

            <!-- /section:basics/footer -->
        </div>
    </div>

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>
				<!-- basic scripts -->

<!--[if !IE]> -->
<script type="text/javascript">
    window.jQuery || document.write("<script src='/Public/qwadmin/js/jquery.js'>" + "<" + "/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='/Public/qwadmin/js/jquery1x.js'>" + "<" + "/script>");
</script>
<![endif]-->
<script type="text/javascript">
    if ('ontouchstart' in document.documentElement) document.write("<script src='/Public/qwadmin/js/jquery.mobile.custom.js'>" + "<" + "/script>");
</script>
<script src="/Public/qwadmin/js/bootstrap.js"></script>

<!-- page specific plugin scripts -->
<script charset="utf-8" src="/Public/kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="/Public/kindeditor/lang/zh_CN.js"></script>
<script src="/Public/qwadmin/js/bootbox.js"></script>
<!-- ace scripts -->
<script src="/Public/qwadmin/js/fuelux/fuelux.tree.js"></script>
<script src="/Public/qwadmin/js/ace-elements.js"></script>
<!-- <script src="/Public/qwadmin/js/ace/elements.wizard.js"></script>
<script src="/Public/qwadmin/js/ace/elements.aside.js"></script> -->
<script src="/Public/qwadmin/js/ace/ace.js"></script>
<script src="/Public/qwadmin/js/ace/ace.ajax-content.js"></script>
<script src="/Public/qwadmin/js/ace/ace.touch-drag.js"></script>
<script src="/Public/qwadmin/js/ace/ace.sidebar.js"></script>
<script src="/Public/qwadmin/js/ace/ace.sidebar-scroll-1.js"></script>
<script src="/Public/qwadmin/js/ace/ace.submenu-hover.js"></script>
<script src="/Public/qwadmin/js/ace/ace.widget-box.js"></script>
<script src="/Public/qwadmin/js/ace/ace.settings.js"></script>
<script src="/Public/qwadmin/js/ace/ace.settings-rtl.js"></script>
<script src="/Public/qwadmin/js/ace/ace.settings-skin.js"></script>
<script src="/Public/qwadmin/js/ace/ace.widget-on-reload.js"></script>
<script src="/Public/qwadmin/js/ace/ace.searchbox-autocomplete.js"></script>
<script src="/Public/qwadmin/js/jquery-ui.js"></script>
			<script type="text/javascript">
                 
                 var $myform=$('#myform'),$myModal=$('#oper-modal'),$addField=$('#addField'),$fieldModel=$('#field-modal');

                 // alert("<?php echo ($_GET['NAME']); ?>");

                           //获取Cookie
                  function getCookie(c_name)
							{
							if (document.cookie.length>0)
							  {
							  c_start=document.cookie.indexOf(c_name + "=")
							  if (c_start!=-1)
							    { 
									    c_start=c_start + c_name.length+1 
									    c_end=document.cookie.indexOf(";",c_start)
									    if (c_end==-1) c_end=document.cookie.length
									    return unescape(document.cookie.substring(c_start,c_end))
							    } 
							  }
							return "";
							}

                             //设置Cookie
				 function setCookie(c_name,value,expiredays)
								{
										var exdate=new Date()
										exdate.setDate(exdate.getDate()+expiredays)
										document.cookie=c_name+ "=" +escape(value)+
										((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
								}
 
                  
                 
                     
                  $(document).on('click','#addField',function(){
                  	      $fieldModel.modal();
                  })
                  $('#btn-search').on('click',function(){
                  	     $('.show-search').animate({
                  	     	height:'50px',
                  	     	// borderWidth:"1px"
                  	     },1000);
  
                  })
                  
				//			  	全选/反选功能
				$(document).on('click', 'th input:checkbox', function() {
					// console.log(this); //input
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox').each(function() {
						this.checked = that.checked;
						// $(this).closest('tr').toggleClass('selected');
						  if(this.checked){
                              $(this).closest('tr').addClass('selected');
					     }else{
                              $(this).closest('tr').removeClass('selected');
					     }
					});
				});
                       // 选中修改样式
				$('tr > td:first-child input:checkbox').on('click',function(){
					     if(this.checked){
                              $(this).closest('tr').addClass('selected');
					     }else{
                              $(this).closest('tr').removeClass('selected');

					     }
				});
                       // 单击一行的时候选中复选框
                   $('tr').on('click',function(){
                           // console.log($(this).find('td:first-child input:checkbox')[0]);
                    $(this).find('td:first-child input:checkbox')[0].checked=!$(this).find('td:first-child input:checkbox')[0].checked;
                          if($(this).find('td:first-child input:checkbox')[0].checked){
                              $(this).addClass('selected');
					       }else{
                              $(this).removeClass('selected');

					     }

                   })
                      //获取所有选中的学生数据的学号
                       
		                function getXh(){
		                	   var xhs=new Array();
		                      var check=$('tbody.datagrid').find('tr>td:first-child input:checkbox');
		                      for(var i=0;i<check.length;i++){
                                     // console.log(check[i].checked);
                                   if(check[i].checked){
                                   	  // xhs.push();
                                   	  var xh=$(check[i]).closest('tr').find('td.xh').html();
                                   	  xhs.push(xh);
                                   }
		                      }	
		                        // console.log(xhs.join(','));
		                        return xhs;

		                }

                        
                       //增加字段核心
		                var $addfields=$('#addfields').find('input');
		                var param=(document.URL).slice((document.URL).indexOf('?')+1);
                          for(var i=0;i<$addfields.length;i++){
                                     // console.log($($addfields[i]).val());
                                // alert(param.indexOf('NAME')!=-1);
                                    	if(param.indexOf($($addfields[i]).val())!=-1){
                                    		  // alert($($addfields[i]).val());
                                    		  $addfields[i].checked=1;
                                    		   $('th.'+$($addfields[i]).val()).css('display','table-cell');
                                              $('td.'+$($addfields[i]).val()).css('display','table-cell');
                                    	}
                                     

					            }   
          	           
		                
              dept={
						url:'',
						saveField:function(){  	
						    //利用表单中只有选中的复选框才能序列化的功能
						    // alert("<?php echo ($_GET['XH']); ?>");
						    // if("<?php echo ($_GET['XH']); ?>"||"<?php echo ($_GET['XM']); ?>"||"<?php echo ($_GET['XBDM']); ?>"||"<?php echo ($_GET['SJQD']); ?>"){
						    // 	alert('dsfd');
						    // } 
						    var cookiestr=getCookie('searchData');
						    if(cookiestr&&("<?php echo ($_GET['XH']); ?>"||"<?php echo ($_GET['XM']); ?>"||"<?php echo ($_GET['XBDM']); ?>"||"<?php echo ($_GET['SJQD']); ?>")){   	
					             window.location.href='<?php echo U("Admin/Student/join");?>?'+cookiestr+'&'+$('#pp').serialize();
						    }else{
					             window.location.href='<?php echo U("Admin/Student/join");?>?'+$('#pp').serialize();           
						    }  
						               
				            // var s='/Admin/Student/join?'+cookiestr+'&'+$('#pp').serialize();
				            // console.log(s);
                      
						},
						add:function(){
                            // 触发 reset 事件,重置表单数据
                            $("input[type=reset]").trigger("click");
							this.url='/admin/Student/addDept';
							dept.dia();
						},
						edit:function(tr){
							this.url='/admin/Student/editDept';
					            var vars=tr.find('td');
					            var arr=new Array();
					            for(var i=1;i<vars.length-2;i++){
                                     arr.push($(vars[i]).html());
					            }					
					           // console.log(arr);		
							    var inputs=$myform.find('input');
							    for(var j=0;j<inputs.length;j++){
							    	$(inputs[j]).val(arr[j]);
                                     console.log($(inputs[j]).val());
							    }							
							dept.dia();							
						},
						save:function(){
							window.location.href=this.url+'?'+$myform.serialize();    
						},
						del:function(tr){
							       // getXh();   
							 if(confirm("您确定要删除选中的数据吗？")) { 
							 	  // alert(getXh().length);
									 	
									 		
									 // $(tr).remove(); 	
							 	  window.location.href='/Admin/Student/delDept?ID='+tr.find('td.xh').html(); 

							 	}                           
							 // window.location.href='/Admin/Student/delDept?ID='+tr.find('td.xh').html(); 
										
							 // console.log(str);
							 // var s='/Admin/Student/delDept?ID='+str; 
							 // console.log(s);
							 	
					     },
                        delAll:function(){
                              var str=getXh().join(',');
                              if(getXh().length>0){
									 if(confirm("您确定要删除选中的数据吗？")) { 
									 	  // alert(getXh().length);
											 	// if(getXh().length>0){
											 		 // var check=$('tbody.datagrid').find('tr>td:first-child input:checkbox');
									      //                 for(var i=0;i<check.length;i++){ 
		                                                          
							        //                            if(check[i].checked){ 
							                                   	 
							        //                                 $(check[i]).closest('tr').remove();
							        //                            }
									      //                 }	 
											  //    }else{
											 	// 	$(tr).remove(); 
											 	// }
									 	  window.location.href='/Admin/Student/delDept?ID='+str; 
									 	} 

                             }else{
                             	  alert('请至少选择一行数据');
                             }
                        },
						search:function(form){
							   // console.log(form);
							       // setCookie('searchData','');
							    var str=form.serialize();
							    console.log(str); 	
							     	setCookie('searchData',str);  
							   // alert(getCookie('searchData'));   
							    window.location.href='<?php echo U("Admin/Student/join");?>?'+form.serialize()+'&'+$('#pp').serialize();
							   // alert('sdfds');
						
						},
						dia:function(){
							//添加，编辑模态框
					            $myModal.modal(); 
						}

	       };
             
				//  屏幕缩小时增删改的样式
				$('[data-rel="tooltip"]').tooltip({
					placement: tooltip_placement
				});

				function tooltip_placement(context, source) {
					var $source = $(source);
					var $parent = $source.closest('table')
					var off1 = $parent.offset();
					var w1 = $parent.width();

					var off2 = $source.offset();
					//var w2 = $source.width();

					if(parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
					return 'left';
				}


         

			</script>